<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/9/12 0012
 * Time: 10:02
 */

namespace App\Services;


trait Singleton
{
    /**
     * @var $_singletonStack
     */
    protected static $_singletonStack;

    public static function getInstance(){
        $class = get_called_class();
        if (empty(static::$_singletonStack[$class])){
            static::$_singletonStack[$class] = new $class();
        }
        return static::$_singletonStack[$class];
    }
}